import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jetour_line/base_widget/base_scaffold.dart';
import 'package:jetour_line/base_widget/image_network_widget.dart';
import 'package:jetour_line/models/public_msg_manger.dart';
import 'package:jetour_line/models/user_info_model.dart';
import 'package:jetour_line/my_colors.dart';
import 'package:jetour_line/utils/aha_utils.dart';
import 'package:jetour_line/utils/extension_int.dart';
import 'package:jetour_line/utils/page_push_utils.dart';

import '../../base_widget/base_image.dart';
import 'mine_collect_page.dart';
import 'mine_common_page.dart';
import 'mine_order_page.dart';
import 'mine_trajectory_page.dart';

class MineScreen extends StatefulWidget {
  const MineScreen({Key? key}) : super(key: key);

  @override
  State<MineScreen> createState() => _MineScreenState();
}

class _MineScreenState extends State<MineScreen> {
  @override
  Widget build(BuildContext context) {
    UserInfoModel userInfoModel = PublicMsgManger().userInfoModel!;
    String head = userInfoModel.avatar;
    String name = userInfoModel.name;
    return BaseScaffold(
        title: "我的",
        body: Padding(
          padding: EdgeInsets.only(
              left: 70.px, right: 70.px, bottom: 70.px, top: 100.px),
          child: Column(

            children: [
              Container(
                alignment: Alignment.center,
                  width: 190.px,
                  height: 190.px,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(95.px)),
                    border: Border.all(width: 2.0, color: Colors.white),
                  ),
                  child: ImageNetworkWidget(
                    head,
                    width: 170.px,
                    height: 170.px,
                    radius: 85.px,
                  )),
              Text(
                name,
                style: TextStyle(
                    fontSize: 34.px,
                    color: MyColors.color333333,
                    fontWeight: FontWeight.w500),
              ),
              SizedBox(
                height: 78.px,
              ),
              for (int i = 0; i < 4; i++) itemWIdget(i)
            ],
          ),
        ));
  }

  Widget itemWIdget(int index) {
    String title = "我的订单";
    String image =  AhaUtils.getImagePath('icon_collect');
    if(index == 0){
      title = "我的共创";
      image =  AhaUtils.getImagePath('icon_wdgc');
    }else if(index == 1){
      title = "我的收藏";
      image = AhaUtils.getImagePath('icon_collect');
    }else if(index == 2){
      title = "我的订单";
      image = AhaUtils.getImagePath('icon_order');
    }else if(index == 3){
      title = "我的轨迹";
      image = AhaUtils.getImagePath('icon_guiji');
    }

    return GestureDetector(
      onTap: () {
        if(index == 0){
          PagePushUtils.push(context, const MineCommonPageScreen());
        }else if(index == 1){
          PagePushUtils.push(context, MineCollectPageScreen());
        }else if(index == 2){
          PagePushUtils.push(context, MineOrderPageScreen());
        }else if(index == 3){
          PagePushUtils.push(context, MineTrajectoryPageScreen());
        }
      },
      child: Padding(
        padding: EdgeInsets.only(bottom: 30.px),
        child: ClipRRect(
            borderRadius: BorderRadius.all(Radius.circular(16.px)),
            child: Container(
              width: double.infinity,
              height: 100.px,
              color: MyColors.white,
              alignment: Alignment.centerLeft,
              child: Row(
                children: [
                  SizedBox(
                    width: 30.px,
                  ),
                  Image(image: AssetImage(image), width: 65.px, height: 65.px),
                  SizedBox(
                    width: 21.px,
                  ),
                  Expanded(
                    child: Text(
                      title,
                      style:
                          TextStyle(fontSize: 30.px, color: MyColors.color333333),
                    ),
                  ),
                  BaseImage(image:'btn_jump',width: 36.px, height: 36.px,),
                  SizedBox(
                    width: 40.px,
                  ),
                ],
              ),
            )),
      ),
    );
  }
}
